var urlArgs = Suningmatch.getUrlArgs();

var vm = new Vue({
    el: '#home',
    data: {
        user: {},
        topic: {},
        zhengnum: 0,
        bestCommList: {},
        commTotal: 0,
        commList: [],
        
        showPop: false
    },
    computed: {
        
    },
    methods: {
        alltopic: function() {
            location.href = "all_contend.html?topicId=" + urlArgs.topicId + "&viewPoint=" + urlArgs.viewPoint + "&personId=" + urlArgs.personId + "&wx_openid=" + urlArgs.wx_openid + "&wx_unionid=" + urlArgs.wx_unionid + "&wx_sex=" + urlArgs.wx_sex + "&wx_headimgurl=" + urlArgs.wx_headimgurl + "&wx_nickname=" + urlArgs.wx_nickname + "&wx_sign=" + urlArgs.wx_sign + "&wx_timestamp=" + urlArgs.wx_timestamp;
        },
        white: function(){
            location.href = "white_topic.html?topicId=" + urlArgs.topicId + "&viewPoint=" + urlArgs.viewPoint + "&personId=" + urlArgs.personId + "&wx_openid=" + urlArgs.wx_openid + "&wx_unionid=" + urlArgs.wx_unionid + "&wx_sex=" + urlArgs.wx_sex + "&wx_headimgurl=" + urlArgs.wx_headimgurl + "&wx_nickname=" + urlArgs.wx_nickname + "&wx_sign=" + urlArgs.wx_sign + "&wx_timestamp=" + urlArgs.wx_timestamp;
        },
        showdelPop: function(){
            vm.showPop = true;
        }
    },
    ready: function() {
        if(location.href.indexOf("wx_openid") == -1) {
            location.href = Suningmatch.wxLogin + encodeURIComponent(location.href);
        }
        this.user = {
            nickname: urlArgs.wx_nickname,
            nickimg: urlArgs.wx_headimgurl
        }
            //test
        urlArgs.topicId = 5;

        //      $.ajax({
        //          type: "post",
        //          url: Suningmatch.DI.getTopic,
        //          data: {
        //              "headPic": urlArgs.wx_headimgurl,
        //              "nickname": urlArgs.wx_nickname,
        //              "openId": urlArgs.wx_openid,
        //              "topicId": urlArgs.topicId
        //          },
        //          dataType: "jsonp",
        //          success: function(data){
        //              console.log(data);
        //          },
        //          error: function(err){
        //              console.log("---")
        //              console.log(err);
        //          }
        //      });

        //this.$http.post(Suningmatch.DI.getTopic, {
        this.$http.get('js/topic.json', {
            "headPic": urlArgs.wx_headimgurl,
            "nickname": urlArgs.wx_nickname,
            "openId": urlArgs.wx_openid,
            "topicId": urlArgs.topicId
        }).then(function(response) {
            //test
            vm.topic = response.data.data[0];

            //this.$http.post(DI.getTopic, {
            this.$http.get('js/commont.json', {
                'start': 0,
                'limit': 10
            }).then(function(response) {
                var comms = response.data.data;
                vm.bestCommList = comms.bestCommList[0];
                vm.commTotal = comms.commList.total;
                vm.commList = comms.commList.rows;
                
            }, function(response) {
                console.log(response);
            });

        }, function(response) {
            console.log("2" + response);
        });
    }
});
